package com.taotao.druid.visitor;

import com.alibaba.druid.sql.ast.statement.SQLSelectGroupByClause;
import com.alibaba.druid.sql.visitor.SQLASTVisitorAdapter;

/**
 * 检查SQL中是否含有group by 关键字
 *
 * @author Qi.qingshan
 * @date 2020/4/25
 */
public class SQLGroupbyVisitor extends SQLASTVisitorAdapter {

    private boolean hasGroupby = false;

    @Override
    public boolean visit(SQLSelectGroupByClause x) {
        this.hasGroupby = true;
        return false;
    }


    /**
     * 是否含有group by 语句
     *
     * @return
     */
    public boolean hasGroupby() {
        return hasGroupby;
    }
}
